//#########################################################################
//                              WackiEngie
//           Copyright (c) 2014 Marc Wacker. All rights reserved.
//#########################################################################

#include "WeGLState.h"

namespace WackiEngine
{

	Vector<Matrix4f>	GLState::_modelViewStack;
	Vector<Matrix4f>	GLState::_projectionStack;

	Matrix4f 			GLState::_view;
	Matrix4f 			GLState::_projection;
	Matrix4f 			GLState::_modelView;


	void GLState::multiplyModelViewMatrix(const Matrix4f& mat)
	{
		_modelView.multiply(mat);
	}

	void GLState::multiplyProjectionMatrix(const Matrix4f& mat)
	{
		_projection.multiply(mat);
	}

	void GLState::pushModelViewMatrix()
	{
		_modelViewStack.push_back(_modelView);
	}

	void GLState::popModelViewMatrix()
	{
		assert(_modelViewStack.size() > 0);
		if(!_modelViewStack.size())
			return;

		_modelView = _modelViewStack.back();
		_modelViewStack.pop_back();
	}

	void GLState::pushProjectionMatrix()
	{
		_projectionStack.push_back(_projection);
	}

	void GLState::popProjectionMatrix()
	{
		assert(_projectionStack.size() > 0);
		if(!_projectionStack.size())
			return;

		_projection = _projectionStack.back();
		_projectionStack.pop_back();
	}

}